package eleven;


import java.util.Arrays;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

public class ListDemo {
    public static void main(String[] args) {
        List<String> list = new LinkedList<>();
        list.add("one");
        list.add("two");
        list.add("three");
        System.out.println(list);
        System.out.println("-----------------------------");
        for (int i = 0; i < list.size(); i++) {
            System.out.println(list.get(i));
        }
        for (String item:list
             ) {
            System.out.println(item);
        }
        Iterator<String> it = list.iterator();
        while(it.hasNext()){
            System.out.println(it.next());
        }
        System.out.println("-----------------------------");

        list.add(1,"seven"); //在list下标为3的位置插入seven
        System.out.println(list);
        String d =list.remove(1);
        System.out.println(d);
        System.out.println(list);

    }

}
